<?php
// +----------------------------------------------------------------------
// | FastXCMS [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.fastxcms.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use app\portal\model\PortalCategoryModel;

// 模块参数列表程序安装
global $configinfo;
$configinfo['listmodule'] = 1;
$configinfo['searchmodule'] = 1;

class SearchController extends HomeBaseController
{
    public function index()
    {
		global $configblock,$configinfo,$configindex,$configbase,$configlang;
		
		$id                  = $this->request->param('id', 0, 'intval');
		
		// 【模块参数程序安装】文章列表条件配置模块
		$configmodule="list";include_once(MODULEPARA_PATH.'/configmodule/configmodule/configmodulewhere.php');
		
        $portalCategoryModel = new PortalCategoryModel();

        $category = $portalCategoryModel->where('id', $id)->where('status', 1)->find();
       
        $this->assign('category', $category);
		
        $keyword = $this->request->param('keyword');

        if (empty($keyword)) {
            $this -> error($configlang['noemptykeyword']);
        }

        $this -> assign("keyword", $keyword);
		
		// 页页标题，关键词，描述
		$seo_title = $configbase['seoconfig']['searchtitle'];
		$seo_keywords = $configbase['seoconfig']['searchkeyword'];
		$seo_description = $configbase['seoconfig']['searchdescription'];
		$seotitle = $keyword;
		if($seo_title)$seotitle .= "-".$seo_title;
		$headmeta = seoheadmeta($seotitle,$seo_keywords,$seo_description,$configbase['config']['name']);
		$this->assign('headmeta', $headmeta);
		
		// 【模块参数程序安装】文章列表配置模块
		$configmodule="list";include_once(MODULEPARA_PATH.'/configmodule/configmodule/configmodule.php');
		
        return $this->fetch('/search');
    }
}
